package com.design.patterns.list.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Wangzhiwen
 */
public class College extends OrganizationComponent {

    List<OrganizationComponent> components = new ArrayList<>();

    public College(String name, String desc) {
        super(name, desc);
    }

    @Override
    protected void add(OrganizationComponent component) {
        components.add(component);
    }

    // 将来实际业务中，College 的 add 和  University add 不一定完全一样
    @Override
    protected void remove(OrganizationComponent component) {
        components.remove(component);
    }

    @Override
    protected List<OrganizationComponent> getChild() {
        return components;
    }

    @Override
    protected void operation() {
        System.out.println("College 节点内容 ------------- ");

        for (OrganizationComponent component : components) {
            component.operation();
        }
    }
}
